﻿//////////////////////////////////////////////////////////////////////////////
//
//  Copyright © 1998-2024 Glodon Company Limited.  All rights reserved.
//
//  Use of this software is subject to the terms of the Glodon license
//  agreement provided at the time of installation or download, or which
//  otherwise accompanies this software in either electronic or hard copy form.  
//
//////////////////////////////////////////////////////////////////////////////

#pragma once

#include "GcmpModelInterface.h"
#include "IDbObject.h"
#include "RegenDataId.h"

namespace gcmp {


    class IDocument;
    class IElement;
    

    /// \brief 元素约束行为接口
    FINAL_INTERFACE class GCMP_MODEL_INTERFACE_EXPORT IElementConstraintBehavior : public IDbObject
    {
        DEFINE_CAST_DERIVED(gcmp::IElementConstraintBehavior, gcmp::IDbObject);

    public:
        /// \brief 生成默认的元素约束行为
        /// \param pDocument 所属文档
        /// \param ownerElementId 所属元素Id
        /// \return 默认的元素约束行为
        static OwnerPtr<IElementConstraintBehavior> CreateDefaultBehavior(IDocument* pDocument, const ElementId& ownerElementId);

        /// \brief 设置该行为所属Element
        /// \param pOwnerElement 所属Element
        /// \return 设置成功返回True, 否则返回false
        virtual bool SetOwnerElement(IElement* pOwnerElement) = 0;

        /// \brief 获得该行为所属Element
        /// \return 所属Element
        virtual IElement* GetOwnerElement() = 0;

        /// \brief 获得该行为所属Element
        /// \return 所属Element
        virtual const IElement* GetOwnerElement() const = 0;

        /// \brief 获得元素所有的族约束信息
        /// \return 元素所有的族约束元素Id
        virtual const std::vector<ElementId>& GetFamilyConstraintIds() const = 0;

        /// \brief 添加族约束信息
        /// \param constraintId 添加的族约束元素Id
        /// \return 添加成功返回true，否则返回false
        virtual bool AddFamilyConstraintId(const ElementId& constraintId) = 0;

        /// \brief 删除族约束信息
        /// \param index 被删除的族约束元素Id在GetFamilyConstraintIds()方法返回的族约束元素Id集合中的索引
        /// \return 删除成功返回true，否则返回false
        virtual bool DeleteFamilyConstraintIdByIndex(size_t index) = 0;

        /// \brief 清除族约束信息
        /// \return 清除成功返回true，否则返回false
        virtual bool ClearFamilyConstraintIds() = 0;

        /// \brief 获得族约束元素Id的关联更新数据唯一标识
        /// \return 关联更新数据唯一标识
        virtual RegenDataId GetFamilyConstraintIdsRdId() const = 0;

        /// \brief 标记族约束元素Id关联更新变化Id
        /// \return void
        virtual void MarkFamilyConstraintIdsRdId() = 0;
    };

}// namespace gcmp


